package com.wanxi.springboot.team.manage.system.service.impl;

import com.wanxi.springboot.team.manage.system.api.CommonResult;
import com.wanxi.springboot.team.manage.system.model.ChangeUserTeamRecord;
import com.wanxi.springboot.team.manage.system.mapper.ChangeUserTeamRecordMapper;
import com.wanxi.springboot.team.manage.system.service.ChangeUserTeamRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 蒋帆
 * @since 2020-12-21
 */
@Service
public class ChangeUserTeamRecordServiceImpl extends ServiceImpl<ChangeUserTeamRecordMapper, ChangeUserTeamRecord> implements ChangeUserTeamRecordService {

    @Autowired(required = false)
    ChangeUserTeamRecordMapper changeUserTeamRecordMapper;
    @Override
    public int addChangeUserTeamRecord(List<ChangeUserTeamRecord> changeUserTeamRecords) {
        return changeUserTeamRecordMapper.addChangeUserTeamRecord(changeUserTeamRecords);
    }

    @Override
    public CommonResult getChangeUserTeamRecords(Map map) {
        int page = (Integer.parseInt((String) map.get("page")) - 1) * Integer.parseInt((String) map.get("limit"));
        map.put("page", page);
        map.put("limit", Integer.parseInt((String) map.get("limit")));
        List<ChangeUserTeamRecord> changeUserTeamRecords = changeUserTeamRecordMapper.getChangeUserTeamRecords(map);
        long count = changeUserTeamRecordMapper.getChangeUserTeamRecordsCount(map);
        return CommonResult.success(changeUserTeamRecords,count);
    }
}
